﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Common;
using CommonDao;
using Domain;
using Domain.Entity;
using QQZoneMarketingDao;
using Spider.Ants;

namespace Spider.Service
{
    public static partial class AntService
    {
        private static readonly object _syncBoot = new object();
        /// <summary>
        /// 保存QQ用户信息
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        internal static bool SaveToQQUserInfo(QQEmail dto)
        {
            return CommonDao.QqEmailDao.SaveToQQUserInfo(dto);

        }
        /// <summary>
        ///  添加QQEmail信息
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        internal static bool AddToQqEmailInfo(QQEmail dto)
        {
            return QQNumberForZoneCatchDao.QqEmailDao.AddToQqEmail(dto);

        }
        /// <summary>
        ///  设置QQ空间已经访问过了
        /// </summary>
        /// <param name="email"></param>
        /// <returns></returns>
        internal static bool SetQQHasVisitedForZone(string email)
        {
            QQZoneMarketingDao.QqEmailDao.SetQQZonHasVisited(email);
            return true;
        }
        /// <summary>
        /// 设置QQ账号已经已访问次数增加，空间
        /// </summary>
        /// <param name="qq"></param>
        /// <returns></returns>
        internal static bool SetQQAcountHasVisitedAddForZone(string qq)
        {
            QQZoneMarketingDao.QQAcountDao.SetQQAcountHasVisitedAdd(qq);
            return true;
        }
        /// <summary>
        /// 判断该Email是否已经被保存过了
        /// </summary>
        /// <param name="email"></param>
        /// <returns></returns>
        internal static bool EmailHasVisited(string email)
        {
            return QQZoneMarketingDao.QqEmailDao.EmailHasVisited(email);
        }
        /// <summary>
        /// 获取QQ新种子号
        /// </summary>
        /// <returns></returns>
        internal static string GetQQNewSeedIngrace()
        {
            lock (_syncBoot)
            {
                var seed = SystemConfigDao.Get(SystemConfigKey.QQEmailSeed);
                UInt64 seed2 = Convert.ToUInt64(seed);
                SystemConfigDao.Update(SystemConfigKey.QQEmailSeed, (++seed2).ToString());
                return seed2.ToString();
            }
        }
        /// <summary>
        ///  设置QQ微博已经访问过了
        /// </summary>
        /// <param name="email"></param>
        /// <returns></returns>
        internal static bool SetQQHasVisitedForWb(string email)
        {
            QQWBDao.QqEmailDao.SetQQWbHasVisitedForWB(email);
            return true;
        }
        /// <summary>
        /// 设置QQ账号已经已访问次数增加,微博
        /// </summary>
        /// <param name="qq"></param>
        /// <returns></returns>
        internal static bool SetQQAcountHasVisitedAddForWb(string qq)
        {
            QQWBDao.QQAcountDao.SetQQAcountHasVisitedAddForWB(qq);
            return true;
        }
    }
}
